package com.cloudptt.wp.ui.dlg;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;

import androidx.annotation.NonNull;

import com.cloudptt.api.product.func.call.group.fsm.video.GroupCallMemberInfo;
import com.cloudptt.wp.R;
import com.cloudptt.wp.ui.call.group.adapter.GroupCallMemberAdapter;

import java.util.List;

public class GroupCallMemberDlg extends Dialog {
    private Context context = null;
    private GroupCallMemberAdapter adapter = null;
    private ListView listView = null;
    public GroupCallMemberDlg(@NonNull Context context, GroupCallMemberAdapter adapter) {
        super(context, R.style.FullWidthDialogTheme); // 使用自定义样式
        this.context = context;
        this.adapter = adapter;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_simple_list); // 绑定自定义布局
        // 初始化控件和事件
        Spinner spinner  = (Spinner)findViewById(R.id.spinner);

        String[] stringArray = context.getResources().getStringArray(R.array.status);
        ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(
                context,
                R.layout.custom_spinner_item,
                stringArray
        );
        spinner.setAdapter(spinnerAdapter);

        listView  = (ListView)findViewById(R.id.test_alertdialog_listview);
        listView.setAdapter(adapter);


        setCanceledOnTouchOutside(true);
        setCancelable(true);
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        Window window = getWindow();
        if (window != null) {
//			window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
            WindowManager.LayoutParams params = window.getAttributes();
            params.width = WindowManager.LayoutParams.MATCH_PARENT;  // 宽度充满屏幕
            params.height = (int) (1500);             // 高度为屏幕一半
            window.setAttributes(params);

            window.setGravity(Gravity.BOTTOM); // 可选：设置对话框位置（如底部）
        }
    }
//    public void refreshData(List<GroupCallMemberInfo> groupCallMemberInfoList)
//    {
//        if(adapter != null)
//        {
//            adapter.refresh(groupCallMemberInfoList);
//            adapter.notifyDataSetChanged();
//        }
//    }
}
